// Decompiled on 周六 2月 22 19:31:49 CST 2025 with Zomboid Decompiler v0.1.3 using Vineflower.
package zombie.core.skinnedmodel.advancedanimation;

import java.util.List;
import zombie.util.Pool;
import zombie.util.PooledArrayObject;
import zombie.util.list.PZArrayUtil;

public class PooledAnimBoneWeightArray extends PooledArrayObject<AnimBoneWeight> {
    private static final PooledAnimBoneWeightArray s_empty = new PooledAnimBoneWeightArray();
    private static final Pool<PooledAnimBoneWeightArray> s_pool = new Pool<>(PooledAnimBoneWeightArray::new);

    public static PooledAnimBoneWeightArray alloc(int count) {
        if (count == 0) {
            return s_empty;
        } else {
            PooledAnimBoneWeightArray pooledAnimBoneWeightArray = s_pool.alloc();
            pooledAnimBoneWeightArray.initCapacity(count, _int -> new AnimBoneWeight[_int]);
            return pooledAnimBoneWeightArray;
        }
    }

    public static PooledAnimBoneWeightArray toArray(List<AnimBoneWeight> list) {
        if (list == null) {
            return null;
        } else {
            PooledAnimBoneWeightArray pooledAnimBoneWeightArray = alloc(list.size());
            PZArrayUtil.arrayCopy(pooledAnimBoneWeightArray.array(), list);
            return pooledAnimBoneWeightArray;
        }
    }

    public static PooledAnimBoneWeightArray toArray(PooledArrayObject<AnimBoneWeight> source) {
        if (source == null) {
            return null;
        } else {
            PooledAnimBoneWeightArray pooledAnimBoneWeightArray = alloc(source.length());
            PZArrayUtil.arrayCopy(pooledAnimBoneWeightArray.array(), (AnimBoneWeight[])source.array());
            return pooledAnimBoneWeightArray;
        }
    }
}
